import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserInfoStore = defineStore('counter', () => {
  const user = JSON.parse(localStorage.getItem('userinfo') || '{}')

  const userinfo = ref({
      adminname: user.adminname || '',
      password: user.password || ''
  })

  function changeUserInfo(user) {
      userinfo.value = user
      localStorage.setItem('userinfo', JSON.stringify(user))
  }

  return {
      userinfo,
      changeUserInfo
  }
})
